<template>
<div class="pcv1-top-nav">
    <div class="nav-box-inner flex">
        <img class="f1 logo" src="../assets/img/logo6.png" @click="goto">
        <span class="f1 pcv1-title-span" @click="goto">智慧书城</span>
        <div class="pcv1-search-box flex">
            <input class="f1" placeholder="请输入书名" v-model="selection">
            <span class="a-mouse fr" @click="select">搜索</span>
        </div>
        <div class="pcv1-before-login flex">
            <span class="a-mouse" v-show="!$store.getters.isLogin" @click="showLogin">登录</span>
            <span class="a-mouse" v-show="$store.getters.isLogin" @click="outLogin">退出</span>
        </div>
    </div> 
</div>
<transition name="fade">
    <Login :ifShow="ifShow" @closeLogin="closeLogin"></Login>
</transition>
<div class="mask" v-show="ifShow"></div>
</template>
<script setup>
import Login from './Login.vue'
import {ref} from 'vue'
import {useRouter} from 'vue-router'
import {useStore} from 'vuex'
const ifShow = ref(false)
const selection = ref('')
const router = useRouter()
const store = useStore()
const goto = ()=>{
    router.push("/books")
}
const showLogin = ()=>{
    ifShow.value = true
}
const closeLogin = ()=>{
    ifShow.value = false
}
const outLogin = ()=>{
    store.commit('outLogin')
}
const select = ()=>{
    if(selection.value!=''){
        router.push('/select/'+selection.value)
    }
}
console.log(ifShow.value)
</script>
<style scoped>
/* 定义过渡动画  */
/* 定义进入过渡的初始状态 */
.fade-enter-from {
    opacity: 0;
    /* 透明度为完全透明 */
    transform: translateY(30px);
    /* 在Y轴上平移 */
}

/* 定义进入过渡和离开过渡生效时的状态 */
.fade-enter-active,
.fade-leave-active {
    /* 为所有属性应用动画，动画时间为2s，动画的速度曲线为平滑过渡 */
    transition: all 2s ease;
}

/* 定义离开过渡的最终状态 */
.fade-leave-to {
    opacity: 0;
    transform: translateY(-30px);
}



.pcv1-top-nav {
    margin: 0 auto;
    width: 100%;
    height: 74px;
    font-size: 14px;
    background: #fff;
    -webkit-box-shadow: 0 4px 12px 0 rgba(0, 0, 0, .08);
    -moz-box-shadow: 0 4px 12px 0 rgba(0, 0, 0, .08);
    box-shadow: 0 4px 12px 0 rgba(0, 0, 0, .08);
    margin-bottom: 20px;
    margin-top: 10px;
}

.nav-box-inner {
    margin: 0 auto;
    width: 1200px;
    height: 100%;
    align-content: center;
}

.pcv1-title-span {
    width: 150px;
    height: 35px;
    line-height: 35px;
    /* margin-right: 30px; */
    overflow: hidden;
    color: #16CA82;
    font-size: 30px;
}

.pcv1-nav-box {
    margin: 0;
    height: 74px;
    background-color: #16CA82;
}

.pcv1-nav-box span {
    margin-left: auto;
    margin-right: auto;
    height: 36px;
    font-size: 24px;
    color: #fff;
}

.pcv1-nav-a {
    line-height: 74px;
    padding: 0 30px;
    font-size: 18px;
    font-weight: bold;
    color: #000;
}

.clearFix::after {
    content: "";
    display: block;
    height: 0;
    overflow: hidden;
    clear: both;
    visibility: hidden;
}

.pcv1-search-box {
    box-sizing: border-box;
    padding: 8px 16px;
    width: 500px;
    height: 36px;
    background: #fff;
    -webkit-border-radius: 18px;
    -moz-border-radius: 18px;
    border-radius: 18px;
    border: 1px solid #746f6f;
    justify-content: space-between;
}

.pcv1-search-box input {
    margin: 4px 12px;
    width: 450px;
    line-height: 28px;
    border: none;
    outline: none;
    text-shadow: none;
    /* -webkit-appearance: none; */
    overflow: visible;
}

.pcv1-search-box span {
    margin: 4px;
    width: 52px;
    height: 28px;
    font-size: 13px;
    line-height: 28px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    background-color: #16CA82;
    color: #ffffff;
    padding-left: 2px
}

.pcv1-before-login span {
    font-size: 16px;
    height: 32px;
    line-height: 32px;
    background-color: #16CA82;
    padding: 8px;
    padding-bottom: 0px;
    padding-top: 0px;
    border-radius: 6px;
    color: #fff;
}
.mask {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, .4);
    z-index: 4
}

div {
    margin: 0 auto;
}

.nav-box {
    height: 60px;
    width: 1200px;
    user-select: none;
    padding: 0px;
    background: #f3f5f9;
    padding: 40px 0 20px;
}

.f1 {
    float: left;
}

.pcv1-book-title {
    margin-right: 60px;
}

.logo {
    /* margin-right: 60px; */
    color: #16CA82;
    font-size: 30px;
    line-height: 36px;
}

img {
    border: none;
    vertical-align: middle;
    overflow: hidden;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    height: 80px;
}

.nav-search {
    margin: 0;
    border: 0;
    width: 540px;
    height: 36px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    background: #fff;
}

.nav-search input {
    margin: 4px 12px;
    width: 450px;
    line-height: 28px;
    border: none;
    outline: none;
    text-shadow: none;
    /* -webkit-appearance: none; */
    overflow: visible;
}

.a-mouse {
    cursor: pointer;
}

.fr {
    float: right;
}

.nav-search span {
    margin: 4px;
    width: 52px;
    height: 28px;
    font-size: 13px;
    line-height: 28px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    background-color: #16CA82;
    color: #ffffff;
    padding-left: 2px
}

.clear-fix::after {
    content: "";
    display: block;
    height: 0;
    overflow: hidden;
    clear: both;
    visibility: hidden;
}

.flex {
    display: flex;
    display: -webkit-flex;
    justify-content: flex-start;
    align-items: center;
}

.pcv1-before-login {
    width: 134px;
    margin: 0;
    float: right;
    text-align: center;
    justify-content: flex-end;
    border: 0;
    /* width: 540px; */
    height: 36px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    background: #fff;
}

.pcv1-before-main {
    width: 134px;
    margin: 0;
    float: left;
    text-align: center;
    justify-content: flex-end;
    border: 0;
    /* width: 540px; */
    height: 36px;
    -webkit-border-radius: 6px;
    -moz-border-radius: 6px;
    border-radius: 6px;
    background: #fff;
    margin-right: 30px;
}

.pcv1-before-main span {
    margin-left: auto;
    margin-right: auto;
}

.pcv1-before-login span {
    margin-left: auto;
    margin-right: auto;
}
</style>